import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router =  new Router({
  mode: 'history',
  linkActiveClass:'on',
  routes: [
    {
      path: '/getMessage',
      name:'GetMessage',
      component:resolve => require(['@/pages/getMessage'], resolve),
    },
    {
      path:'*',
      component:resolve => require(['@/pages/notFind'], resolve),
    },
    {
      path:'/',
      redirect:'/payIndex'
    },
    {
      path: '/payIndex',
      name: 'payIndex',
      component: resolve => require(['@/pages/payIndex'], resolve),
      redirect:'/enterPage',
      children:[
        // 入口页面
        {
          path:'/enterPage',
          name:'enterPage',
          component: resolve => require(['@/pages/enterPage'], resolve),
        },
        // 支付操作
        {
          path:'/payOperation',
          name:'payOperation',
          component: resolve => require(['@/pages/payOperation'], resolve)
        },
        // 支付步骤页面
        {
          path:'/payFor',
          name:'payFor',
          component: resolve => require(['@/pages/payFor'], resolve)
        },
        // 支付查询页
        {
          path:'/payQuery',
          name:'payQuery',
          component: resolve => require(['@/pages/payQuery'], resolve)
        }
      ]

    }
  ]
})

// router.beforeEach((to,from,next)=>{
//   if(from.name=='payFor' && to.name=='payOperation'){
//     history.pushState(null, null, location.href)
//   }else{
//     next();
//   }
// })

export default router;
